<template>
  <div>
    <van-field label='姓名' v-model='form.name'/>
    <van-field label='金额' v-model='form.money'/>
    <van-field label='机构名称' v-model='form.company'/>
    客户经理
    <select v-model='form.manager_id'>
      <option :value="i.id" v-for='i in managelist' :key="i">{{ i.name }}</option>
    </select>
    注册来源
    <select v-model='form.refromid'>
      <option :value="i.id" v-for='i in resourcelist' :key="i">{{ i.name }}</option>
    </select>

    <van-button @click='submit'>提交</van-button>
  </div>
</template>

<script>
import myaxios from 'axios'
export default {
  name: "company",
  data(){
    return{
      form:{},
      managelist:[],
      resourcelist:[]
    }
  },
  methods: {
    getmanagelist(){
      myaxios({url:'http://127.0.0.1:5000/managelist',method:'get'}).then(res=>{
        this.managelist=res.data.list
        console.log(res)
        this.getresourcelist()
      })
    },
    getresourcelist(){
      myaxios({url:'http://127.0.0.1:5000/resourcelist',method:'get'}).then(res=>{
        this.resourcelist=res.data.list
      })
    },
    submit(){
      myaxios({url:'http://127.0.0.1:5000/customer_reg',method:'post',data:{data:this.form}}).then(res=>{
        console.log(res)
      })
    }
  },
  mounted() {
    this.getmanagelist()
    // this.getresourcelist()
  },
}
</script>

<style scoped>

</style>